package com.qixianxian.dao;
import com.qixianxian.pojo.User;
import com.qixianxian.util.DBUtil;

import java.sql.ResultSet;
import java.sql.SQLException;

public class UserDaoImpl implements UserDao{
    @Override
    public User Login(String uname, String pwd) {
        String command = "SELECT * FROM t_user WHERE uname = ? AND pwd = ?";
        ResultSet rs = DBUtil.select(command, uname, pwd);
        User u = null;
        try {
            if (rs.next()) {
                String name = rs.getString("uname");
                String password = rs.getString("pwd");
                int sex = rs.getInt("sex");
                u = new User(name, password, sex);
            }
        }
        catch (SQLException e) {
            e.printStackTrace();
        }
        return u;
    }
}
